﻿using H.Eyes.Remotings;
using H.Hands.Remotings;
using H.Remotings;
using System;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;

namespace H.Driver.Client
{
    public class HRemotingFactory : IRemotingFactory
    {
        /// <summary>
        /// 静态代码块
        /// </summary>
        static HRemotingFactory()
        {
            ChannelServices.RegisterChannel(new TcpClientChannel(), false);
        }

        ///<inheritdoc/>
        public IRemotingEyeFactory GetEyeFactory(string hostName, int port)
        {
            return Activator.GetObject(typeof(IRemotingEyeFactory), $"tcp://{hostName}:{port}/eye") as IRemotingEyeFactory;
        }

        ///<inheritdoc/>
        public IRemotingHandFactory GetHandFactory(string hostName, int port)
        {
            return Activator.GetObject(typeof(IRemotingHandFactory), $"tcp://{hostName}:{port}/hand") as IRemotingHandFactory;
        }
    }
}
